package com.player.thirdGroup.common;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
public class ResltEntity<T> implements Serializable {
    private Integer status;

    private String Msg;

    private T dataEnt;

    private Map<String,Object> dataMap = new HashMap<>();

    public void setKeyAndValueForDataMap(String key , String value){
        dataMap.put(key,value);
    }

    public Object getValueByKeyForDataMap(String key){
        return dataMap.get(key);
    }

    private ResltEntity() {
    }

    public ResltEntity(Integer status, String msg) {
        this.status = status;
        Msg = msg;
    }

    public ResltEntity(Integer status, String msg, T dataEnt) {
        this.status = status;
        Msg = msg;
        this.dataEnt = dataEnt;
    }

    public static <T> ResltEntity<T> createSuccess(){
        return new ResltEntity<T>(SysDefine.SUCCESS,"操作成功！");
    }
    public static <T>ResltEntity<T> createError(){
        return new ResltEntity<T>(SysDefine.ERROR,"系统错误！");
    }
    public static <T>ResltEntity<T> createWarning(){
        return new ResltEntity<T>(SysDefine.WARNING,"系统错误！");
    }
    public static <T>ResltEntity<T> createSuccessMsg(String msg){
        return new ResltEntity<T>(SysDefine.SUCCESS,msg);
    }
    public static <T>ResltEntity<T> createErrorMsg(String msg){
        return new ResltEntity<T>(SysDefine.ERROR,msg);
    }
    public static <T>ResltEntity<T> createWarningMsg(String msg){
        return new ResltEntity<T>(SysDefine.WARNING,msg);
    }
}
